package com.sv.dao;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.sv.base.BaseDao;
import com.sv.model.SdContent;
import com.sv.model.SdContentCriteria;
import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.orm.ibatis.SqlMapClientFactoryBean;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

@Service
@Configurable(autowire = Autowire.BY_TYPE)
public class SdContentDAOImpl implements SdContentDAO {

    /**
     * This field was generated by Apache iBATIS ibator. This field corresponds
     * to the database table sd_content
     * 
     * @ibatorgenerated Thu Mar 22 10:11:52 CST 2012
     */
     @Autowired
     @Qualifier("sqlMapClient")
    private SqlMapClient sqlMapClient;

    public SqlMapClient getSqlMapClient() {
        return sqlMapClient;
    }

    public void setSqlMapClient(SqlMapClient sqlMapClient) {
        this.sqlMapClient = sqlMapClient;
    }

    // /**
    // * This method was generated by Apache iBATIS ibator. This method
    // * corresponds to the database table sd_content
    // *
    // * @ibatorgenerated Thu Mar 22 10:11:52 CST 2012
    // */
    // public SdContentDAOImpl() {
    // this.sqlMapClient = super.getSqlMapClient();
    // }

    /**
     * This method was generated by Apache iBATIS ibator. This method
     * corresponds to the database table sd_content
     * 
     * @ibatorgenerated Thu Mar 22 10:11:52 CST 2012
     */
    public int countByExample(SdContentCriteria example) throws SQLException {
        Integer count = (Integer) sqlMapClient.queryForObject(
                "sd_content.ibatorgenerated_countByExample", example);
        return count.intValue();
    }

    /**
     * This method was generated by Apache iBATIS ibator. This method
     * corresponds to the database table sd_content
     * 
     * @ibatorgenerated Thu Mar 22 10:11:52 CST 2012
     */
    public int deleteByExample(SdContentCriteria example) throws SQLException {
        int rows = sqlMapClient.delete(
                "sd_content.ibatorgenerated_deleteByExample", example);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator. This method
     * corresponds to the database table sd_content
     * 
     * @ibatorgenerated Thu Mar 22 10:11:52 CST 2012
     */
    public int deleteByPrimaryKey(Integer contentId) throws SQLException {
        SdContent key = new SdContent();
        key.setContentId(contentId);
        int rows = sqlMapClient.delete(
                "sd_content.ibatorgenerated_deleteByPrimaryKey", key);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator. This method
     * corresponds to the database table sd_content
     * 
     * @ibatorgenerated Thu Mar 22 10:11:52 CST 2012
     */
    public void insert(SdContent record) throws SQLException {
        sqlMapClient.insert("sd_content.ibatorgenerated_insert", record);
    }

    /**
     * This method was generated by Apache iBATIS ibator. This method
     * corresponds to the database table sd_content
     * 
     * @ibatorgenerated Thu Mar 22 10:11:52 CST 2012
     */
    public void insertSelective(SdContent record) throws SQLException {
        sqlMapClient.insert("sd_content.ibatorgenerated_insertSelective",
                record);
    }

    /**
     * This method was generated by Apache iBATIS ibator. This method
     * corresponds to the database table sd_content
     * 
     * @ibatorgenerated Thu Mar 22 10:11:52 CST 2012
     */
    public List selectByExample(SdContentCriteria example) throws SQLException {
        List list = sqlMapClient.queryForList(
                "sd_content.ibatorgenerated_selectByExample", example);
        return list;
    }

    /**
     * This method was generated by Apache iBATIS ibator. This method
     * corresponds to the database table sd_content
     * 
     * @ibatorgenerated Thu Mar 22 10:11:52 CST 2012
     */
    public SdContent selectByPrimaryKey(Integer contentId) throws SQLException {
        SdContent key = new SdContent();
        key.setContentId(contentId);
        SdContent record = (SdContent) sqlMapClient.queryForObject(
                "sd_content.ibatorgenerated_selectByPrimaryKey", key);
        return record;
    }

    /**
     * This method was generated by Apache iBATIS ibator. This method
     * corresponds to the database table sd_content
     * 
     * @ibatorgenerated Thu Mar 22 10:11:52 CST 2012
     */
    public int updateByExampleSelective(SdContent record,
            SdContentCriteria example) throws SQLException {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = sqlMapClient.update(
                "sd_content.ibatorgenerated_updateByExampleSelective", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator. This method
     * corresponds to the database table sd_content
     * 
     * @ibatorgenerated Thu Mar 22 10:11:52 CST 2012
     */
    public int updateByExample(SdContent record, SdContentCriteria example)
            throws SQLException {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = sqlMapClient.update(
                "sd_content.ibatorgenerated_updateByExample", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator. This method
     * corresponds to the database table sd_content
     * 
     * @ibatorgenerated Thu Mar 22 10:11:52 CST 2012
     */
    public int updateByPrimaryKeySelective(SdContent record)
            throws SQLException {
        int rows = sqlMapClient.update(
                "sd_content.ibatorgenerated_updateByPrimaryKeySelective",
                record);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator. This method
     * corresponds to the database table sd_content
     * 
     * @ibatorgenerated Thu Mar 22 10:11:52 CST 2012
     */
    public int updateByPrimaryKey(SdContent record) throws SQLException {
        int rows = sqlMapClient.update(
                "sd_content.ibatorgenerated_updateByPrimaryKey", record);
        return rows;
    }

    /**
     * This class was generated by Apache iBATIS ibator. This class corresponds
     * to the database table sd_content
     * 
     * @ibatorgenerated Thu Mar 22 10:11:52 CST 2012
     */
    private static class UpdateByExampleParms extends SdContentCriteria {
        private Object record;

        public UpdateByExampleParms(Object record, SdContentCriteria example) {
            super(example);
            this.record = record;
        }

        public Object getRecord() {
            return record;
        }
    }
}
